<?php

App::uses('AppModel', 'Model');

class Settings extends AppModel {
    
    public $useTable   = 'settings';
    public $primaryKey = 'key';
    
    public function load() {
        return (object)$this->find('list', array(
            'fields' => array('Settings.key', 'Settings.value')
        ));
    }
    
    public function saveThemAll($settings) {
        $data = array();
        foreach ($settings as $key=>$value) {
            $data[] = array( 'Settings' => array(
                'key'   => $key,
                'value' => $value
            ));
        }
        return $this->saveAll($data);
    }
}
